Bottle1 = Widget.extend({
	ctor:function(){
		this._super();
		this.init();
		this.setTag(TAG_BOTTLE_ALL);
	},
	init:function(){
		this.body=new Button(this,10,TAG_BOTTLE1,"#bottle1.png",this.callback);
		var bottle_lib=new Button(this,11,TAG_LID,"#lid3.png",this.callback);
		bottle_lib.setPosition(cc.p(5, this.body.height*0.45));

		var flow=new Button(this.body,9,TAG_KETTLE_FLOW1,"#flow.png",this.callback);
		flow.setAnchorPoint(cc.p(1,1));
		flow.setRotation(65);
		flow.setOpacity(0);
		flow.setScale(1.5,1);
		flow.setPosition(cc.p(40,this.body.height*0.95));
	},
	openLib:function(){
		var ber = cc.bezierBy(1.5,[cc.p(50,70),cc.p(60,-70),cc.p(60,-120)]);
		var rotate = cc.rotateTo(1.5, 180);
		var spawn = cc.spawn(ber, rotate);
		var seq = cc.sequence(spawn,cc.callFunc(function() {
			this.getChildByTag(TAG_LID).setRotation(0);
			this.getChildByTag(TAG_LID).setSpriteFrame("lid4.png");
			gg.flow.next();
		},this));
		this.getChildByTag(TAG_LID).runAction(seq);
	},
	showFlow:function(){
		var fadein=cc.fadeIn(0.1)
		var fadeout=cc.fadeOut(0.1);
		var rotate=cc.rotateBy(1,25);
		var body=this.getChildByTag(TAG_BOTTLE1)
		var flow=body.getChildByTag(TAG_KETTLE_FLOW1);
		flow.runAction(cc.sequence(fadein,rotate,fadeout));
	},
	callback:function(p){
		var func = cc.callFunc(this.actionDone, this);
		switch(p.getTag()){
		case TAG_LID:
			this.openLib();
			break;
		case TAG_BOTTLE1:
			var lid=this.getChildByTag(TAG_LID);
			this.body.runAction(cc.sequence(cc.moveBy(1,cc.p(-gg.c_width*0.1,80)),cc.spawn(cc.rotateTo(1,-85),cc.sequence(cc.delayTime(0.8),func)),cc.delayTime(1),cc.rotateTo(1,0),cc.callFunc(function() {
				p.removeFromParent(true);
				lid.setVisible(false);
				gg.flow.next();
			},this)));
			break;
		default:
			break;
		}
	},
	actionDone:function(p){
		switch(p.getTag()){
		case TAG_BOTTLE1:
			var beaker=ll.run.getChildByTag(TAG_BEAKER);
			beaker.showLine();
			this.showFlow();
			break;
		default:
			break;
		}
	}
});
